package com.cgtu.cgtucalculator.test;

import com.cgtu.cgtucalculator.util.CanCountable;
import org.junit.jupiter.api.Test;

public class testCountable {
   @Test
   public void Test1(){
      CanCountable canCountable=new CanCountable();
      try {
         String str=Math.E+"^(8*(8+9+√(8)))";
         //存在误差
         canCountable.isErrorStr(str);
         System.out.println(str+" 预期结果：7.7805783570085673888476853329425e+68  实际结果： "+canCountable.getResult());
      } catch (Exception e) {
         throw new RuntimeException(e);
      }
   }
   @Test
   public void Test2(){
      CanCountable canCountable=new CanCountable();
      try {
         String str="2^(8*(8+9+sqr(6)))";
         //存在误差
         canCountable.isErrorStr(str);
         System.out.println(str+" 预期结果：4.3322963970637732180912721627236e+127  实际结果： "+canCountable.getResult());
      } catch (Exception e) {
         throw new RuntimeException(e);
      }
   }
   @Test
   public void Test3(){
      CanCountable canCountable=new CanCountable();
      try {
         String str="1";
         //存在误差
         canCountable.isErrorStr(str);
         System.out.println(str+" 预期结果：1  实际结果： "+canCountable.getResult());
      } catch (Exception e) {
         throw new RuntimeException(e);
      }
   }


   //此处测试存在误差
   @Test
   public void Test4(){
      CanCountable canCountable=new CanCountable();
      try {
         String str="sin((4)!)*2";
         //存在误差
         canCountable.isErrorStr(str);
         System.out.println(str+" 预期结果：2.8134732861516  实际结果： "+canCountable.getResult());
      } catch (Exception e) {
         throw new RuntimeException(e);
      }
   }

   @Test
   public void Test5(){
      CanCountable canCountable=new CanCountable();
      try {
         String str="(1.2*(0.2^2.1+√(1.01)))";
         canCountable.isErrorStr(str);
         System.out.println(str+" 预期结果：1.2468493908155043  实际结果： "+canCountable.getResult());
      } catch (Exception e) {
         throw new RuntimeException(e);
      }
   }
   @Test
   public void Test6(){
      CanCountable canCountable=new CanCountable();
      try {
         String str="2+2*3^2+4";
         canCountable.isErrorStr(str);
         System.out.println(str+" 预期结果：24  实际结果： "+canCountable.getResult());
      } catch (Exception e) {
         throw new RuntimeException(e);
      }
   }

   @Test
   public void Test7(){
      CanCountable canCountable=new CanCountable();
      try {
         String str="((2*3^2)+4)";
         //特殊情况
         canCountable.isErrorStr(str);
         System.out.println(str+" 预期结果：22  实际结果： "+canCountable.getResult());
      } catch (Exception e) {
         throw new RuntimeException(e);
      }
   }
}
